{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 随机数生成六个班的考试成绩，3门考试：Python、数学、语文。每个班50人"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[ 36,  65,  76],\n",
       "        [ 39,  89,  43],\n",
       "        [ 18,  32,  37],\n",
       "        [  9,  32,   5],\n",
       "        [ 22,  75,  35],\n",
       "        [ 63,  99,  99],\n",
       "        [ 34,  45,  88],\n",
       "        [ 14,   9,  87],\n",
       "        [ 71,  17,  32],\n",
       "        [ 36,  45,  48],\n",
       "        [ 64,   8,  73],\n",
       "        [ 63,  72,  70],\n",
       "        [ 60,  84,  66],\n",
       "        [ 78,  28,  19],\n",
       "        [ 26,  74,  65],\n",
       "        [ 77,  37,  36],\n",
       "        [ 84,  74,  79],\n",
       "        [ 29,  38,  40],\n",
       "        [ 92,   7,  32],\n",
       "        [  9,  74,   6],\n",
       "        [ 24,  29,  65],\n",
       "        [ 61,  51,  30],\n",
       "        [ 21,  86,   6],\n",
       "        [ 76,  48,  78],\n",
       "        [ 45,   3,  27],\n",
       "        [  8,  80,  32],\n",
       "        [ 72,  13,  26],\n",
       "        [ 51,  31,  10],\n",
       "        [ 82,  47,  94],\n",
       "        [ 42,  41,  78],\n",
       "        [ 37,  38,  74],\n",
       "        [ 13,  11,  11],\n",
       "        [ 43,  86,  26],\n",
       "        [  2,  58,   4],\n",
       "        [ 91,  23,  30],\n",
       "        [ 45,  52,  65],\n",
       "        [ 69,  23,  78],\n",
       "        [ 41,  48,  89],\n",
       "        [ 49,  86,  52],\n",
       "        [ 49,  69,  61],\n",
       "        [ 31,  20,   0],\n",
       "        [ 99,  54,   6],\n",
       "        [ 30,  97,  22],\n",
       "        [ 71,  24,  67],\n",
       "        [ 97,  77,  66],\n",
       "        [  0,  68,  20],\n",
       "        [  2,  60,  47],\n",
       "        [ 62,   5,  28],\n",
       "        [ 37,  55,  14],\n",
       "        [ 53,   2,  19]],\n",
       "\n",
       "       [[ 51,  83,  54],\n",
       "        [ 52,  58,  92],\n",
       "        [  0,  22,   8],\n",
       "        [  9,  84,  62],\n",
       "        [ 95,  78,  91],\n",
       "        [100,  99,   0],\n",
       "        [ 92,  81,  46],\n",
       "        [ 63,   8,  37],\n",
       "        [ 55,  43,  26],\n",
       "        [ 19,  98,  33],\n",
       "        [ 12,  52,  26],\n",
       "        [ 55,  68,   5],\n",
       "        [  1,  74,  25],\n",
       "        [ 85,  59,  12],\n",
       "        [100,  14,  40],\n",
       "        [ 31,  67,  59],\n",
       "        [ 25,  35,  58],\n",
       "        [ 18,  55,  79],\n",
       "        [ 72,   7,  96],\n",
       "        [ 61,  92,  14],\n",
       "        [ 75,  50,   7],\n",
       "        [ 83,  64,  21],\n",
       "        [ 35,  34,  39],\n",
       "        [ 83,  60,  14],\n",
       "        [ 39,  36,  43],\n",
       "        [ 17,  96,  42],\n",
       "        [ 96,  84,  91],\n",
       "        [ 34,  88,  22],\n",
       "        [ 53,  40,  63],\n",
       "        [ 78,  51,  10],\n",
       "        [ 55,  58,  81],\n",
       "        [ 90,  17,  35],\n",
       "        [ 85,  72,  71],\n",
       "        [ 62,  91,  29],\n",
       "        [ 59,  86,  95],\n",
       "        [  6,  47,  90],\n",
       "        [ 32,   5,  16],\n",
       "        [ 85,   1,  92],\n",
       "        [ 76,  39,  46],\n",
       "        [ 55,  74,  72],\n",
       "        [ 90,  63,   3],\n",
       "        [ 91,  99,  18],\n",
       "        [  8,  69,   2],\n",
       "        [  6,   2,  51],\n",
       "        [  7,   9,  51],\n",
       "        [ 59,   3,  37],\n",
       "        [ 67,  81,  89],\n",
       "        [ 17,  25,  39],\n",
       "        [ 38,  38,  96],\n",
       "        [ 45,  80,   6]],\n",
       "\n",
       "       [[ 89,  23,   4],\n",
       "        [  1,  10,   2],\n",
       "        [ 53,  16,  76],\n",
       "        [ 61,  15,  53],\n",
       "        [ 64,  27,  36],\n",
       "        [ 47,  14,  64],\n",
       "        [ 87,  18,   5],\n",
       "        [ 49,  36,  99],\n",
       "        [ 95,  98,  90],\n",
       "        [  0,  77,  29],\n",
       "        [ 62,  31,  21],\n",
       "        [ 82,  59,  15],\n",
       "        [ 78,  53,  30],\n",
       "        [ 10,  70,  30],\n",
       "        [ 10,  56,  99],\n",
       "        [ 47,  45,  13],\n",
       "        [  4,  28,  58],\n",
       "        [ 99,  54,  72],\n",
       "        [  7,   3,  71],\n",
       "        [ 18,  21,  49],\n",
       "        [ 71,  59,  34],\n",
       "        [ 97,  90,  90],\n",
       "        [ 28,  30,  37],\n",
       "        [  4,  27,   6],\n",
       "        [ 48,  11,  16],\n",
       "        [ 29,  31,  20],\n",
       "        [ 34,  16,  91],\n",
       "        [ 62,  90,  74],\n",
       "        [ 44,  51,  84],\n",
       "        [ 94,  64,   8],\n",
       "        [ 75,   7,  46],\n",
       "        [ 82,  85,  49],\n",
       "        [ 27,   7,  46],\n",
       "        [ 38,  40,  58],\n",
       "        [ 66,   4,   0],\n",
       "        [ 60,  40,  79],\n",
       "        [ 82,  41,  28],\n",
       "        [ 79,  65,  18],\n",
       "        [ 75,  20,  54],\n",
       "        [ 44,  13,  19],\n",
       "        [ 47,   5,   6],\n",
       "        [ 11,  99,  38],\n",
       "        [ 52,  48,  75],\n",
       "        [ 38,  90,  96],\n",
       "        [ 78,  54,  25],\n",
       "        [ 18,  78,  59],\n",
       "        [ 48,  75,  71],\n",
       "        [ 85,  34,  30],\n",
       "        [ 15,  73,  46],\n",
       "        [ 33,  34,  13]],\n",
       "\n",
       "       [[ 67,  76,  47],\n",
       "        [ 89,  20,  78],\n",
       "        [ 97,  60,  27],\n",
       "        [ 97,  48,  91],\n",
       "        [ 15,  72,  91],\n",
       "        [ 41,  49,  83],\n",
       "        [ 91,   6,  34],\n",
       "        [ 55,  19,  17],\n",
       "        [  6,  37,  47],\n",
       "        [ 73,   2,  15],\n",
       "        [ 18,   7,  69],\n",
       "        [ 40,  33,   4],\n",
       "        [ 57,   4,  16],\n",
       "        [ 37,   5,  80],\n",
       "        [  1,  27,  56],\n",
       "        [ 83,  69,  53],\n",
       "        [  4,   1,  22],\n",
       "        [ 55,  75,  85],\n",
       "        [ 92,  16,  51],\n",
       "        [ 61,  26,   9],\n",
       "        [ 53,  37,  95],\n",
       "        [ 87,  70,  79],\n",
       "        [ 45,  76,  64],\n",
       "        [ 53,  20,  78],\n",
       "        [ 92,  48,  99],\n",
       "        [ 45,  19,  25],\n",
       "        [ 49,  63,  84],\n",
       "        [ 79,  71,  95],\n",
       "        [  4,   8,  92],\n",
       "        [ 88,  17,  43],\n",
       "        [ 41,  33,  78],\n",
       "        [ 25,  37,  64],\n",
       "        [ 64,  27,  70],\n",
       "        [  2,  34,  82],\n",
       "        [  0,   9,  66],\n",
       "        [ 36,  37,  89],\n",
       "        [ 27,  23,  42],\n",
       "        [ 99,  67,  18],\n",
       "        [ 50,  72,  13],\n",
       "        [ 70,  61,  97],\n",
       "        [ 84,  37,  77],\n",
       "        [  5,  44,  14],\n",
       "        [  3,   2,  60],\n",
       "        [ 27,  95,  16],\n",
       "        [ 99, 100,  99],\n",
       "        [ 32,  80,  77],\n",
       "        [  9,   1,  56],\n",
       "        [ 49,  40,   2],\n",
       "        [ 24,  75,   6],\n",
       "        [ 37,  91,  87]],\n",
       "\n",
       "       [[ 97,  85,  51],\n",
       "        [ 39,   2,  67],\n",
       "        [ 98,  16,  77],\n",
       "        [ 41,  97,  17],\n",
       "        [ 86,  86,  52],\n",
       "        [ 17,  25,  81],\n",
       "        [ 45,  46,  94],\n",
       "        [ 33,  27,  54],\n",
       "        [  5,  29,  89],\n",
       "        [  1,  10,  18],\n",
       "        [ 25,  42,  70],\n",
       "        [ 65,  36,  61],\n",
       "        [ 29,  15,  23],\n",
       "        [ 95,  21,  77],\n",
       "        [ 19,  39,  69],\n",
       "        [ 22,  51,  19],\n",
       "        [ 85,  75,  64],\n",
       "        [ 67,  60,   0],\n",
       "        [  8,  85,  57],\n",
       "        [ 48,  66,  65],\n",
       "        [ 25,  98,  69],\n",
       "        [ 35,  18,  30],\n",
       "        [ 93,  55,  52],\n",
       "        [ 33,  80,  47],\n",
       "        [ 21,  51, 100],\n",
       "        [ 30,  68,  61],\n",
       "        [ 72,  30,  28],\n",
       "        [  0,  90,   1],\n",
       "        [ 79,  93,  17],\n",
       "        [ 63,  64,  76],\n",
       "        [ 18,  74,  62],\n",
       "        [ 19,  16,  18],\n",
       "        [ 16,  66,  49],\n",
       "        [ 97,  82,  42],\n",
       "        [ 68,  84,  14],\n",
       "        [ 41,  33,  25],\n",
       "        [ 85,   9,  80],\n",
       "        [ 16,  96,  23],\n",
       "        [  0,   5,  81],\n",
       "        [ 60,  76,  42],\n",
       "        [ 16,  92,  35],\n",
       "        [ 76,  19,  39],\n",
       "        [ 81,  21,  99],\n",
       "        [ 96,  17,  63],\n",
       "        [ 72,  28,  69],\n",
       "        [ 85,  72,   0],\n",
       "        [ 61, 100,  77],\n",
       "        [ 74,  13,  74],\n",
       "        [ 72,   4,  64],\n",
       "        [ 73,  55,  52]],\n",
       "\n",
       "       [[ 37,  93,   3],\n",
       "        [  3,  52,  24],\n",
       "        [ 65,   9,  37],\n",
       "        [ 95,  92,  97],\n",
       "        [ 41,  10,  69],\n",
       "        [ 59,  94,  75],\n",
       "        [ 14,  28,  97],\n",
       "        [ 71,  88,  14],\n",
       "        [ 23,  80,  72],\n",
       "        [ 29,  84,  58],\n",
       "        [ 35,  61,  76],\n",
       "        [ 52,  97,   2],\n",
       "        [ 53,   6,   1],\n",
       "        [ 73,  86,   8],\n",
       "        [ 87,  17,  18],\n",
       "        [ 60,  57,  62],\n",
       "        [ 69,  89,  78],\n",
       "        [ 64,  23,  62],\n",
       "        [ 11,  92,  89],\n",
       "        [ 40,  31,  36],\n",
       "        [ 98,   4,  38],\n",
       "        [ 17,  94,   8],\n",
       "        [ 91,  35,  50],\n",
       "        [ 57,  90,  54],\n",
       "        [ 81,  69,   0],\n",
       "        [ 21,  60,  86],\n",
       "        [ 86,  15,  79],\n",
       "        [  8,  69,  34],\n",
       "        [ 91,  91,  99],\n",
       "        [ 44,  50,  59],\n",
       "        [ 94,  22,  64],\n",
       "        [ 91,  28,  11],\n",
       "        [  6,  41,   2],\n",
       "        [ 50,  41,  98],\n",
       "        [ 27,   6,  50],\n",
       "        [ 17,  18,  86],\n",
       "        [ 90,  75,  63],\n",
       "        [ 85,  57,  68],\n",
       "        [ 98,  66,  55],\n",
       "        [ 60,  84,  81],\n",
       "        [100,  84,  82],\n",
       "        [ 38,  19,  86],\n",
       "        [ 91,  32,  29],\n",
       "        [ 73,  74,  75],\n",
       "        [  9,  94,  20],\n",
       "        [ 80,  36,  98],\n",
       "        [ 56,  30,  99],\n",
       "        [ 16,   1,  80],\n",
       "        [ 78,  80,  89],\n",
       "        [ 10,  38,  42]]])"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "import numpy as np\n",
    "# 三维数组, 6个班, 50个人, 3门课\n",
    "a = np.random.randint(0,101, size=(6,50,3))\n",
    "a"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 将六个班的考试成绩进行合并得到score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(300, 3)"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 纵向合并 6个班\n",
    "score = np.vstack(a)\n",
    "score.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 生成性别数组sex，水平叠加数组sex和score得到data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0,\n",
       "        1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0,\n",
       "        1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1,\n",
       "        1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0,\n",
       "        1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1,\n",
       "        0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0,\n",
       "        0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0,\n",
       "        0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0,\n",
       "        1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0,\n",
       "        1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0,\n",
       "        1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1,\n",
       "        0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0,\n",
       "        0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1,\n",
       "        1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1]])"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 设置条件\n",
    "cond =  np.random.randint(0,2,size=(1,score.shape[0]))\n",
    "cond"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男', '男',\n",
       "       '男'], dtype='<U1')"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "male = np.array(['男'] *score.shape[0])\n",
    "male "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女', '女',\n",
       "       '女'], dtype='<U1')"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "female = np.array(['女'] *score.shape[0])\n",
    "female "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(300, 1)"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 用where 替换字符串, 如果是1 则是男, 是0则是女, 然后.T转置, 由于是1行300列, 想水平合并分数, 则需要转置\n",
    "sex = np.where(cond,male,female).T\n",
    "sex."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(300, 4)"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#水平合并\n",
    "data = np.hstack((score, sex))\n",
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 分别计算男女生各科成绩统计指标：最小值、最大值、平均分、中位数、标准差"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(300, 4)"
      ]
     },
     "execution_count": 115,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([15179, 14523, 14926])"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(data[:,0:3].astype(int))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(144, 4)"
      ]
     },
     "execution_count": 135,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取所有男生数据\n",
    "index_male = np.argwhere(data[:,3] == '男')\n",
    "male = data[index_male]\n",
    "# 三维矩阵变为二维矩阵\n",
    "male = male.reshape(male.shape[0],male.shape[2])\n",
    "male.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(156, 4)"
      ]
     },
     "execution_count": 134,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取所有女生数据\n",
    "index_female = np.argwhere(data[:,3] =='女')\n",
    "female = data[index_female]\n",
    "# 三维矩阵变为二维矩阵\n",
    "female = female.reshape(female.shape[0],female.shape[2])\n",
    "female.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([29.73, 29.39, 29.71])"
      ]
     },
     "execution_count": 168,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 男生的最小值、最大值、平均分、中位数、标准差\n",
    "mean = np.around(male[:,0:3].astype(int).mean(axis = 0),2)\n",
    "median = np.median(male[:,0:3].astype(int),axis=0)\n",
    "min =  male[:,0:3].astype(int).min(axis = 0)\n",
    "max = male[:,0:3].astype(int).max(axis = 0)\n",
    "std = np.around(male[:,0:3].astype(int).std(axis = 0),2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 172,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([56.5, 51. , 51. ])"
      ]
     },
     "execution_count": 172,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 女生的最小值、最大值、平均分、中位数、标准差   保留两位小数\n",
    "mean = np.around(female[:,0:3].astype(int).mean(axis = 0),2)\n",
    "median = np.median(female[:,0:3].astype(int),axis=0)\n",
    "min =  female[:,0:3].astype(int).min(axis = 0)\n",
    "max = female[:,0:3].astype(int).max(axis = 0)\n",
    "std = np.around(female[:,0:3].astype(int).std(axis = 0),2)\n",
    "median"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.7.4 64-bit",
   "language": "python",
   "name": "python37464bit6f52b298c29940a4a5589df2f2d0f39c"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
